<?php
class ArticleAction extends CommonAction{
	
	public function article_add(){
			
		$Sorts = M('Sorts');
		$list=$Sorts->order('path')->select();
		$this->assign('list',$list);
		$this->display();
		
	}
	
	public function article_list(){
			
		$Article   =  M('Article');
		import('ORG.Util.Page');
		$count=$Article->count();
		$Page  = new Page($count,2);
		$Page->setConfig('theme',"%totalRow% %header% %nowPage%/%totalPage% 页 %first% %prePage% %linkPage% %nextPage% %end%");

		$nowPage = isset($_GET['p'])?$_GET['p']:1;
		$list = $Article->order('id')->page($nowPage.','.$Page->listRows)->select();
		$show = $Page->show();
		$this->assign('page',$show);
		$this->assign('list',$list);
		$this->display();
		
	}
	
	public function article_insert(){
		$Article   =   D('Article');
		
		if($Article->create()){
			$result  =  $Article->add();
			if($result){
				$this->success('添加成功');
			}else{
				$this->error('添加失败');
			}
		}else{
			$this->error($Article->getError());
		}
	}
}



?>